import { TreeSelect } from "antd";
import React, { useState, useImperativeHandle } from "react";
import Notfound from "../notFound/not-found";

const ZtreeSelect = (props) => {
    const { treeData, fieldNames, defaultValue, placeholder = "", allowClear = false } = props

    const [treeLine, setTreeLine] = useState(true);
    const [showLeafIcon, setShowLeafIcon] = useState(false);


    return (
        <TreeSelect
            fieldNames={fieldNames}
            showSearch
            treeLine={
                treeLine && {
                    showLeafIcon,
                }
            }
            style={{
                width: '100%',
                flex: 1
            }}
            dropdownStyle={{
                maxHeight: 400,
                overflow: 'auto',
            }}
            placeholder={placeholder}
            allowClear={allowClear}
            treeDefaultExpandAll
            notFoundContent={<Notfound />}
            treeData={treeData}
            defaultValue={defaultValue}//传入当前默认值
            filterTreeNode={true}
            // onChange={onChange}
            // value={value}
            labelInValue={true}
            treeNodeFilterProp="comSName"
            {...props}

        />
    )

}

export default ZtreeSelect;